var app = getApp();
Page({
  data: {
    items: [],
  },

  onShow: function () {
    let tableID = 37878
    let Product = new wx.BaaS.TableObject(tableID)
    Product.find().then(res => {
      //console.log(res.data.objects[0].title)
      this.setData({
        items: res.data.objects
      })
    }, err => {
      wx.showModal({
        title: '当前数据库为空！',
      })
    })
  },
delete:function(e){
  var buttonvalue = e.currentTarget.dataset.weixin

  wx.showModal({
    title: '提示',
    content: '确定要删除吗？',
    success: function (sm) {
      if (sm.confirm) {
        let tableID1 = 37878
        let MyTableObject = new wx.BaaS.TableObject(tableID1)
        let query = new wx.BaaS.Query()
        let weixin = buttonvalue
        query.contains('weixin', weixin)
        MyTableObject.delete(query).then(res => {
          wx.showModal({
            title: '删除成功！'
          })
          wx.navigateTo({
            url: '../Roommate/Roommate',
          })
        }, err => {
          console.log('faile')
        })
      } else if (sm.cancel) {
        console.log('用户点击取消')
      }
    }
  })
 
}

})
